package com.lufei4.chestnut.view;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.blankj.utilcode.util.GsonUtils;
import com.lufei4.chestnut.R;
import com.lufei4.chestnut.network.BaseActivity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @ProjectName: Chestnut
 * @Package: com.lufei4.chestnut.view
 * @ClassName: Main2
 * @Description: java类作用描述
 * @Author: liushijiang 15833013864@163.com
 * @CreateDate: 2020/12/26 22:00
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/12/26 22:00
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */

public class MainActivity2 extends BaseActivity {
    @BindView(R.id.editTextTextPersonName)
    EditText editTextTextPersonName;
    @BindView(R.id.editTextTextPassword)
    EditText editTextTextPassword;
    @BindView(R.id.button)
    Button button;
    @BindView(R.id.button2)
    Button button2;
    @BindView(R.id.content)
    TextView content;

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void initView() {

    }
    public static String JSONTokener(String in) {
        // consume an optional byte order mark (BOM) if it exists
        if (in != null && in.startsWith("\ufeff")) {
            in = in.substring(1);
        }
        return in;
    }
    private void initData() {
        String string = getResources().getString(R.string.json_data);


//        MCCIDBean mccidBean = GsonUtils.fromJson(string, MCCIDBean.class);
        try {
            JSONObject jsonObject = new JSONObject(JSONTokener(string));
//            JSONArray datasss = jsonObject.optJSONArray("datasss");
//            assert datasss != null;
//            String mcc = datasss.getJSONObject(0).optString("MCC");
            Log.d("lufei111sss","ssss"+"___"+jsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
            Log.d("lufei111eee","eeee"+e.toString());
        }

    }



    public static String decode(String unicodeStr) {
        if (unicodeStr == null) {
            return null;
        }
        StringBuffer retBuf = new StringBuffer();
        int maxLoop = unicodeStr.length();
        for (int i = 0; i < maxLoop; i++) {
            if (unicodeStr.charAt(i) == '\\') {
                if ((i < maxLoop - 5) && ((unicodeStr.charAt(i + 1) == 'u') || (unicodeStr.charAt(i + 1) == 'U')))
                    try {
                        retBuf.append((char) Integer.parseInt(unicodeStr.substring(i + 2, i + 6), 16));
                        i += 5;
                    } catch (NumberFormatException localNumberFormatException) {
                        retBuf.append(unicodeStr.charAt(i));
                    }
                else
                    retBuf.append(unicodeStr.charAt(i));
            } else {
                retBuf.append(unicodeStr.charAt(i));
            }
        }
        return retBuf.toString();
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.button, R.id.button2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.button:
                initData();
                break;
            case R.id.button2:
                break;
        }
    }
}
